package org.shop.controller;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.shop.dao.Impl.ProductTypeDaoImpl;
import org.shop.dao.ProductTypeDao;
import org.shop.entity.ProductType;
import org.shop.vo.ResponseData;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * 查询所有商品类型信息
 * @author ZJL
 * @date 2024-12-11
 */
@WebServlet("/list_all_type.do")
public class ListAllProductTypeServlet extends BaseController {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        //实例化 DAO
        ProductTypeDao productTypeDao = new ProductTypeDaoImpl();
        //调用 DAO 对象的方法
        List<ProductType> list = productTypeDao.selectAll();
        print(resp,success(200,list,"success"));
    }
}
